package com.show.mytest;

import com.show.mytest.entity.Student;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class Test03_ObjectStream {
    public static void main(String[] args) throws Exception {
        // 创建一个学生对象
        Student student = new Student(1,"张飒","男");
        // 创建一个文件转换输出流对象
        ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("F:/配置1.txt"));
        // 调用写出方法,写出对象
        os.writeObject(student);
        // 创建文件转换输入流对象
        ObjectInputStream is = new ObjectInputStream(new FileInputStream("F:/配置1.txt"));
        // 调用写入方法,读入对象
        Student student1 = (Student) is.readObject();
        // 输出读入的对象
        System.out.println(student1);
    }
}
